﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace VNet.VisiSuite.VisiCentral.ViewModels
{
    public class CellViewModel : BaseViewModel
    {
        private string _display_name;
        private string _display_name_font_color;
        private string _percent;
        private string _alarm_font_color;
        private string _alarm_color;
        private string _rollup_font_color;
        private string _rollup_color;
        private bool _flash;
        private bool _enable;
        private bool _selected;
        private string _reason_code;
        private bool _down;  // is the braider down or running?
        private bool _acknowledged;
        private DateTime _start_time;
        private long _status;
        private bool _offline;
        private string _background_color;

        //private const string DEFAULT_BG_IMAGE = "/VisiCentral;component/Resources/Images/btnPanel75x40.png";
        //private const string SELECTED_BG_IMAGE = "/VisiCentral;component/Resources/Images/btnPanel75x40Gray.png";

        public CellViewModel(string display_name, int id, string alarm_font_color, string alarm_color, string rollup_font_color, string rollup_color, bool enable, bool down)
        {
            _display_name = display_name;
            _display_name_font_color = "#FFFFFFFF";
            this.ID = id;
            _alarm_font_color = alarm_font_color;
            _alarm_color = alarm_color;
            _rollup_font_color = rollup_font_color;
            _rollup_color = rollup_color;
            _enable = enable;
            _down = down;
            Hide = (id == 0 ? Visibility.Hidden : Visibility.Visible);
            _flash = false;
            _selected = false;


        }

        public int ID
        {
            get;
            set;
        }

        public string DisplayName
        {
            get { return _display_name; }
        }

        public string DisplayNameFontColor
        {
            get { return _display_name_font_color; }
            set
            {
                if (_display_name_font_color != value)
                {
                    _display_name_font_color = value;
                    OnPropertyChanged("DisplayNameFontColor");
                }
            }
        }

        public string AlarmFontColor
        {
            get { return _alarm_font_color; }
            set
            {
                if (_alarm_font_color != value)
                {
                    _alarm_font_color = value;
                    OnPropertyChanged("AlarmFontColor");
                }
            }
        }
        public string AlarmColor
        {
            get { return _alarm_color; }
            set
            {
                if (_alarm_color != value)
                {
                    _alarm_color = value;
                    OnPropertyChanged("AlarmColor");
                }
            }
        }
        public string RollupFontColor
        {
            get { return _rollup_font_color; }
            set
            {
                if (_rollup_font_color != value)
                {
                    _rollup_font_color = value;
                    OnPropertyChanged("RollupFontColor");
                }
            }
        }

        public string RollupColor
        {
            get { return _rollup_color; }
            set
            {
                if (_rollup_color != value)
                {
                    _rollup_color = value;
                    OnPropertyChanged("RollupColor");
                }
            }
        }

        public string Percent
        {
            get { return _percent; }
            set
            {
                if (_percent != value)
                {
                    _percent = value;
                    OnPropertyChanged("Percent");
                }
            }
        }
        public bool Flash
        {
            get { return _flash; }
            set
            {
                if (_flash != value)
                {
                    _flash = value;
                    OnPropertyChanged("Flash");
                }
            }
        }
        public bool Enable
        {
            get { return _enable; }
            set
            {
                if (_enable != value)
                {
                    _enable = value;
                    OnPropertyChanged("Enable");
                }
            }
        }

        public bool Down
        {
            get { return _down; }
            set { _down = value; }
        }

        public string ReasonCode
        {
            get { return _reason_code; }
            set { _reason_code = value; }
        }

        public bool Acknowledged
        {
            get { return _acknowledged; }
            set { _acknowledged = value; }
        }

        public DateTime StartTime
        {
            get { return _start_time; }
            set { _start_time = value; }
        }

        public long Status
        {
            get { return _status; }
            set { _status = value; }
        }

        public bool Offline
        {
            get { return _offline; }
            set { _offline = value; }
        }

        public bool TabletOffline
        {
            get;
            set;
        }

        public bool NoData
        {
            get;
            set;
        }

        public Visibility Hide
        {
            get;
            set;
        }

        //public string BackgroundImage
        //{
        //    get { return _bg_image; }
        //    set
        //    {
        //        if (_bg_image != value)
        //        {
        //            _bg_image = value;
        //            NotifyPropertyChanged("BackgroundImage");
        //        }
        //    }
        //}

        public string BackgroundColor
        {
            get { return _selected ? "#FF808080" : "#FF0C0C0C"; }
        }

        public bool Selected
        {
            get { return _selected; }
            set
            {
                if (_selected != value)
                {
                    _selected = value;
                    OnPropertyChanged("BackgroundColor");
                    //BackgroundImage = _selected ? SELECTED_BG_IMAGE : DEFAULT_BG_IMAGE;
                }
            }
        }

        #region Navigation Framwork
        public override void OnNavigate(object obj)
        {
        }

        public override void OnLeave()
        {
        }
        #endregion
    }
}
